Date: Mon, 11 Nov 1996 17:12:36 GMT
Server: NCSA/1.5
Content-type: text/html
Last-modified: Fri, 04 Oct 1996 07:14:26 GMT
Content-length: 2279

<HTML>
<HEAD>
<TITLE>Quiz 2 - CS 302 Fall 1996 - Section 4</TITLE>
</HEAD>
<BODY>


<H5 ALIGN=RIGHT>Name: _______________________________ </H5>
<H4 ALIGN=CENTER>
  <!WA0><!WA0><!WA0><!WA0><!WA0><!WA0><A HREF="http://www.cs.wisc.edu/~cs302">CS 302</A>
  Fall 1996 - <!WA1><!WA1><!WA1><!WA1><!WA1><!WA1><A HREF="http://www.cs.wisc.edu/~milo/cs302.html">Section 4</A>
</H4> 
<H4 ALIGN=CENTER>Quiz 2</H4>
<H5 ALIGN=CENTER>Wednesday, October 2, 1996</H5> 
<hr><br>

This quiz is 20 total points.  Please write legibly.  If I can't read
it, I can't grade it.  You have until 5 minutes after the class period
ends to finish.

Good luck.

<OL>
  <LI> (2 points) What does the ``magic'' type ``<TT>const char *</TT>''
allow us to do?

        <br> <br> <br> <br> <br> <br>

  <LI> (2 points)

State one difference between a local variable and a <EM>call-by-value</EM>
parameter?

        <br> <br> <br> <br> <br> <br>
       
  <LI> (2 points) What does a <tt>void</tt> keyword at the beginning of a
function header or prototype mean?

        <br> <br> <br> <br> <br> <br>

  <LI> (2 points) Based on what was said in class, when are ``global''
variables acceptible to use?

        <br> <br> <br> <br> <br> <br>

  <LI> (2 points) Give one reason to use a <EM>call-by-reference</EM>(&) parameter.
 
        <br> <br> <br> <br> <br> <br>
        <br> <br> <br> <br> <br>


<H5 ALIGN=CENTER>- Over - </H5>


  <LI> (5 points) What is the output of the following program?

<PRE>
#include&ltiostream.h&gt

void height(int total_inches, int& inches, int& feet);

int main() 
{
  int my_height = 78;
  int height_inches, height_feet;

  height(my_height, height_inches, height_feet);
  cout << "I am " << height_feet << " feet, ";
  cout << height_inches << " inches tall." << endl;
}

void height(int total_inches, int& inches, int& feet)
{
  inches = total_inches % 12;
  feet = total_inches / 12;
}

</PRE>

<br> <br> <br> <br> <br> <br>

  <LI> (5 points) Exercise 7, page 184: Write a <tt>void</tt> function
definition for a function called <tt>add_tax</tt>.  The function
<TT>add_tax</tt> has two formal parameters: <tt>tax_rate</TT> which is the
amount of sales tax expressed as a percentage and <tt>cost</tt> which is
the cost of an item before tax.  The function changes the value of
<tt>cost</tt> so that it includes sales tax.
</OL>


</BODY>
</HTML>


